/*******************************************************************************
* @copyright: Shenzhen Hangshun Chip Technology R&D Co., Ltd
* @filename:  main.c
* @brief:     Main program body
* @author:    AE Team
* @version:   V1.0.0/2025-07-16
*             1.Initial version
* @log:
*******************************************************************************/


/* Includes ------------------------------------------------------------------*/
#include "main.h"


/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define BSRR_VAL1 0x0002
#define BSRR_VAL2 0x0080

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef        GPIO_InitStructure;

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       file (KEIL_startup_hk32g003.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_hk32g003.c file
     */

  /* GPIOD Periph clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD, ENABLE);

  /* Configure PD01 in output pushpull mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
  GPIO_Init(GPIOC, &GPIO_InitStructure);

  while(1)
  {
    /* Set PD01 and PC07 */
    GPIOD->BSRR = BSRR_VAL1;
    GPIOC->BSRR = BSRR_VAL2;

    /* Reset PD01 and PC07 */
    GPIOD->BRR = BSRR_VAL1;
    GPIOC->BRR = BSRR_VAL2;

    /* Set PD01 and PC07 */
    GPIOD->BSRR = BSRR_VAL1;
    GPIOC->BSRR = BSRR_VAL2;

    /* Reset PD01 and PC07 */
    GPIOD->BRR = BSRR_VAL1;
    GPIOC->BRR = BSRR_VAL2;

    /* Set PD01 and PC07 */
    GPIOD->BSRR = BSRR_VAL1;
    GPIOC->BSRR = BSRR_VAL2;

    /* Reset PD01 and PC07 */
    GPIOD->BRR = BSRR_VAL1;
    GPIOC->BRR = BSRR_VAL2;

    /* Set PD01 and PC07 */
    GPIOD->BSRR = BSRR_VAL1;
    GPIOC->BSRR = BSRR_VAL2;

    /* Reset PD01 and PC07 */
    GPIOD->BRR = BSRR_VAL1;
    GPIOC->BRR = BSRR_VAL2;

    /* Set PD01 and PC07 */
    GPIOD->BSRR = BSRR_VAL1;
    GPIOC->BSRR = BSRR_VAL2;

    /* Reset PD01 and PC07 */
    GPIOD->BRR = BSRR_VAL1;
    GPIOC->BRR = BSRR_VAL2;
  }
}


#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif


